//
// See the file COPYING for redistribution information.
//

#ifndef __NAIPAX_DIGEST_HPP__
#define __NAIPAX_DIGEST_HPP__

#include <string>

namespace Naipax {
    const unsigned int DIGEST_SIZE = 16;
    const unsigned int DIGEST_ASCII_SIZE = 32 + 1;

    /** This class is used to generate digest for user data.
     */
    class Digest {
    public:

        /** Make digest in binary form
         *
         * @param rData User data
         * @param pDigest Generated digest
         * @exception Error::INVALID_ARGUMENT will be thrown if pDigest
         *            is NULL
         */
        static void Make(const std::string &rData, char *pDigest);

        /** Make digest in ascii form
         *
         * @param rData User data
         * @param pDigest Generated digest
         * @exception Error::INVALID_ARGUMENT will be thrown if pDigest
         *            is NULL
         */
        static void MakeAscii(const std::string &rData, char *pAsciiDigest);

        /** Convert binary digest into ascii
         *
         * @param rData User data
         * @param pDigest Generated digest
         * @exception Error::INVALID_ARGUMENT will be thrown if pDigest
         *            is NULL or pAsciiDigest is NULL
         */
        static void BinaryToAscii(const char *pDigest, char *pAsciiDigest);
    };
};

#endif // __NAIPAX_DIGEST_HPP__
